export const TimeFormat = (date) => {
  const Time = [
    {
      name: "月",
      value: 2592000000
    },
    {
      name: "天",
      value: 86400000
    },
    {
      name: "小时",
      value: 3600000
    },
    {
      name: "分钟",
      value: 60000
    }
  ]
  let d = new Date(date);
  let now = new Date();
  if (d-now>0) throw new Error("时间不能为未来时间")
  let diff = now - d;
  if (d<60000){
    return "刚刚"
  }
  if (diff > 3153600000){
    return "很久以前"
  }
  for (let i = 0; i < Time.length; i++) {
    if (diff/Time[i].value>=1){
      return `${Math.ceil(diff/Time[i].value)}${Time[i].name}前`
    }
  }
}